<!--  -->
<template>
  <div class="dialog-ip4">
    <el-dialog title="编辑国家黑名单" :visible.sync="dialogShow" :close-on-click-modal="false">
      <div class="add-container-u">
        <el-form>
          <el-form-item label="国家选择：" :label-width="formLabelWidth" style="margin-bottom: 0px;">
            <el-checkbox-group v-model="checkList">
              <el-checkbox v-for="country in countrys" :label="country" :key="country">{{country}}</el-checkbox>
            </el-checkbox-group>
          </el-form-item>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="close">关闭</el-button>
        <el-button size="small" type="primary" @click="saveclose">保存</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {countryOptions} from '@/config/countryip.js'
export default {
  props: {
    blackarea: {
      type: Array
    },
    resetData: {
      type: Function
    }
  },
  created () {
  },
  data () {
    return {
      dialogShow: false,
      formLabelWidth: '120px',
      countrys: countryOptions,
      checkList: []
    }
  },
  watch: {
  },
  methods: {
    show () {
      this.dialogShow = true
      this.checkList = this.blackarea
    },
    close () {
      this.dialogShow = false
      this.checkList = []
    },
    saveclose () {
      this.$jpost('/hostip4/update-ip4release-blackarea', JSON.parse(JSON.stringify(this.checkList))).then(response => {
        if (response) {
          this.resetData(response)
        }
      })
      this.close()
    }
  },
  components: {
  }
}
// const countryOptions = ['中国', '美国', '英国', '德国', '法国', '日本', '韩国', '马来西亚', '俄罗斯', '新加坡', '西班牙', '意大利', '葡萄牙', '菲律宾', '澳大利亚', '加拿大', '印度']
</script>

<style scoped lang="scss">
</style>
